<!--#include file="lib/utf-8.asp"-->
<!--#include file="lib/connopen.asp"-->
<!--#include file="lib/asp-common-lib.asp"-->
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>CC的办公系统</title>
<!--#include file="lib/plugins.asp"-->
<style type="text/css">
  .ui-datepicker table {
    border: 0;
  }
  .yform label{
    display:inline;
  }
</style>
<script type="text/javascript">
  $(function() {

  });
</script>
<!--#include file="lib/js-google-analytics.asp"-->
</head>
<%
if not CheckPostFlag(session("aaPostFlag"),3,5) then call JumpErrorPage(2)
purchase_id=saferequest("purchase_id",1)
if request.form().count>0 then
    back_id=request.form.key(1)
    back_id=clng(split(back_id,"_")(1))
    sql="delete * from goods where goods_id="&back_id    
	conn.BeginTrans
	on error resume next
    call ExecuteCommand(sql,false)
	if err.number=0 then 
		conn.CommitTrans  '如果没有conn错误，则执行事务提交
	else
		conn.RollbackTrans '否则回滚
		'回滚后的其他操作
		'strerr=err.Description
		url=request.ServerVariables("http_host")&request.ServerVariables("url")
		Response.Write "数据库错误！<br /><font color=red>Error # " & CStr(Err.Number) & "<br />" & Err.Description & "<br />Source: " & Err.Source &"<br />错误页面："&url&"</font><br />"
		Response.End
	end if
    
end if
%>
<body>
<!--#include file="lib/header.asp"-->
<!--#include file="lib/nav.asp"-->
<div id="main">
<!--#include file="lib/col1.asp"-->
<!--#include file="lib/col2.asp"-->
  <div id="col3" role="main">
    <div id="col3_content" class="clearfix">
              <form name="form1" method="POST">
              <input type="hidden" name="purchase_id" value="<%=purchase_id%>" />
      <div>
      进货批次信息
        <table class="full">
          <thead>
            <tr>
              <th scope="col">批号</th>
              <th scope="col">供货商</th>
              <th scope="col">进货日期</th>
              <th scope="col">进货单号</th>
              <th scope="col">进货联系人</th>
              <th scope="col">总金额</th>
              <th scope="col">经手人</th>
              <th scope="col">开票</th>
              <th scope="col">备注</th>
            </tr>
          </thead>
          <tbody>
        <%
          set rs = Server.CreateObject("ADODB.Recordset")
          sql="select * from purchase_sql where purchase_id="&purchase_id
          rs.open sql,conn,1,1
          if not rs.eof then
        %>
            <tr>
              <td><%=rs("purchase_id")%></td>
              <td><%=rs("vendor_name")%></td>
              <td><%=rs("purchase_date")%></td>
              <td><%=rs("purchase_sn")%></td>
              <td><%=rs("purchase_contact")%></td>
              <td><%=rs("purchase_price")%></td>
              <td><%=rs("fullname")%></td>
              <td><%if rs("purchase_bill") then response.write("√") else response.write("<input type='button' value='开票' />")%></td>
              <td><%=rs("purchase_memo")%></td>
            </tr>
        <%
          end if
          rs.close
          set rs=nothing
        %>
          </tbody>
        </table> 
      </div>
      <div>
      该批次进货文具清单
        <table id="goods_list" class="full">
          <thead>
            <tr>
              <th>序号</th>
              <th>分类</th>
              <th>文具名</th>
              <th>品牌</th>
              <th>型号</th>
              <th>规格</th>
              <th>单位</th>
              <th>数量</th>
              <th>库存</th>
              <th>单价</th>
              <th>金额</th>
              <th>备注</th>
              <th>操作</th>
            </tr>
          </thead>
          <tbody>
      <%
        sum_price=0
        set rs = Server.CreateObject("ADODB.Recordset")
        sql="select * from goods_all where goods_purchase="&purchase_id
        rs.open sql,conn,1,1
        do while not rs.eof
      %>
            <tr>
              <td><%=rs.AbsolutePosition%></td>
              <td><%=rs("class_name")%></td>
              <td><a href="goods.asp?goods_id=<%=rs("goods_id")%>"><%=rs("goods_name")%></a></td>
              <td><%=rs("brand_name")%></td>
              <td><%=rs("goods_model")%></td>
              <td><%=rs("goods_spec")%></td>
              <td><%=rs("unit_name")%></td>
              <td><%=rs("goods_quantity")%></td>
              <td><%=rs("goods_stock")%></td>
              <td><%=rs("goods_unitprice")%></td>
              <td><%=rs("goods_price")%></td>
              <td><%=rs("goods_memo")%></td>
              <td><%
              if rs("goods_quantity")=rs("goods_stock") then
              %>
                <input type="submit" name="back_<%=rs("goods_id")%>" value="退货" />
                <% end if%>
                </td>
            </tr>
      <%
          sum_price=sum_price+rs("goods_price")
          rs.movenext()
        loop
        rs.close()
        set rs=nothing
      %>
            <tr>
              <td>合计</td>
              <td></td>
              <td></td>
              <td></td>
              <td></td>
              <td></td>
              <td></td>
              <td></td>
              <td></td>
              <td></td>
              <td><%=sum_price%></td>
              <td></td>
              <td></td>
            </tr>
          </tbody>
        </table>
      </div>
                </form>
    </div>
  </div>
</div>
<!--#include file="lib/footer.asp"-->
</body>
</html>
<!--#include file="lib/connclose.asp"-->

